import java.io.*;
import java.util.*;

/**
 * @author soffo
 *
 */
/**
 * @author soffo
 *
 */
public class VideoCopyController {
	VideoCopyFileManager copyFileManager ;
    VideoCopyModel copyModel;
    VideoCopyView copyView;

    /**
     * @param copyModels
     */
    public void addVideoCopy(ArrayList<VideoCopyModel> copyModels)
    {
    	try {
    		copyFileManager = new VideoCopyFileManager();
			copyFileManager.writeToFile(copyModels);
			//copyFileManager.writeToFile(model);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
    }

    /**
     * @param copyNumber
     * @throws ClassNotFoundException
     * @throws IOException
     */
    public void DeleteVideoCopy(int copyNumber) throws ClassNotFoundException, IOException
    {


		copyFileManager = new VideoCopyFileManager();
		ArrayList<VideoCopyModel> copyModels = copyFileManager.readFromFile();
		VideoCopyModel videoCopyModel1 = new VideoCopyModel();
		ArrayList<VideoCopyModel> arrayList = videoCopyModel1.deleteMovieByNumber(copyNumber, copyModels);
	    copyFileManager.updateFile(arrayList);


    }

	/**
	 * @param copyNumber
	 * @throws ClassNotFoundException
	 * @throws IOException
	 */
	public void SearchVideoCopy(Integer copyNumber) throws ClassNotFoundException, IOException {

			copyFileManager = new VideoCopyFileManager();

			ArrayList<VideoCopyModel> copyModels = copyFileManager
					.readFromFile();

			VideoCopyModel videoCopyModel1 = new VideoCopyModel();

			ArrayList<VideoCopyModel> arrayList = videoCopyModel1
					.findMovieByNumber(copyNumber, copyModels);

			for (VideoCopyModel videoCopyModel:arrayList) {

				System.out.println(videoCopyModel);
			}


	}

	/**
	 * @throws ClassNotFoundException
	 * @throws IOException
	 */
	public void updateView() throws ClassNotFoundException, IOException
	{
		copyFileManager = new VideoCopyFileManager();
		ArrayList<VideoCopyModel>videos = copyFileManager.readFromFile();
		copyView = new VideoCopyView();
		copyView.displayVideoCopyMenu(videos);
	}

}
